package com.example.sea.core.common.utils;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * 数学验证码
 */
public class VerificationCodeUtil {

    public static Map<String,String> create(){
        Map<String,String> resultMap=new HashMap<>();
        Random random = new Random();
        int num1=random.nextInt(10);
        int op_num=random.nextInt(3);
        int num2=(random.nextInt(9)+1);
        Integer randomCode=0;
        switch(op_num){
            case 0:
                randomCode = num1+num2;
                resultMap.put("randomCodeKey",String.valueOf(num1)+" + "+String.valueOf(num2)+" = ?");
                break;
            case 1:
                randomCode = num1-num2;
                resultMap.put("randomCodeKey",String.valueOf(num1)+" - "+String.valueOf(num2)+" = ?");
                break;
            case 2:
                randomCode = num1*num2;
                resultMap.put("randomCodeKey",String.valueOf(num1)+" * "+String.valueOf(num2)+" = ?");
                break;
        }
        resultMap.put("randomCodeValue",String.valueOf(randomCode));
        return resultMap;
    }
}
